package com.d3.pomodoro.activity


import android.content.pm.ActivityInfo
import android.os.Build
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.d3.pomodoro.AppApplication
import com.d3.pomodoro.utils.SoftKeyBoardController

abstract class BaseActivity : AppCompatActivity() {

    lateinit var softKeyBoardChangeListener: SoftKeyBoardController

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        //禁止横屏
        requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
        AppApplication.getInstance().addActivity(this)
        softKeyBoardChangeListener = SoftKeyBoardController(this)
    }

    override fun onDestroy() {
        super.onDestroy()
        AppApplication.getInstance().removeActivity(this)
    }


    fun changeStatusBarColor(colorId: Int) {
        if (Build.VERSION.SDK_INT >= 21) {
            window.statusBarColor = resources.getColor(colorId)
        }
    }


}